﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;

namespace Reservi
{
    /// <summary>
    /// 块的状态
    /// </summary>
    enum BlockStatus
    {
        Blank,
        Black,
        White
    }

    /// <summary>
    /// 块对象
    /// </summary>
    class Block
    {
        /// <summary>
        /// 状态坐标
        /// </summary>
        public BlockStatus Status { get; set; }

        /// <summary>
        /// 矩阵坐标
        /// </summary>
        public Point Point { get; set; }       

        public Block()
        {
            //初始状态空白
            Status = BlockStatus.Blank;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="point">矩阵坐标，与物理相反</param>
        public Block(Point point)
        {
            Status = BlockStatus.Blank;
            Point = point;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="x">矩阵x</param>
        /// <param name="y">矩阵y</param>
        public Block(int x, int y)
        {
            Status = BlockStatus.Blank;
            Point = new Point(x, y);        
        }

        /// <summary>
        /// 画当前格子
        /// </summary>
        /// <param name="g">画图句柄</param>
        /// <param name="rec">当前block的rectangle</param>
        public void Draw(Graphics g, Rectangle rec)
        {
            switch (Status)
            {
                case BlockStatus.Black:
                    g.DrawImage(Properties.Resources.black, rec);
                    break;
                case BlockStatus.White:
                    g.DrawImage(Properties.Resources.white, rec);
                    break;
            }
        }
        /// <summary>
        /// 处理鼠标点击，改变当前块的颜色
        /// </summary>
        /// <param name="IsBlack"></param>
        public void MouseDown(bool IsBlack)
        {
            this.Status = IsBlack ? BlockStatus.Black : BlockStatus.White;
        }

    }
}
